package com.mframe.web;

/**
 * 预留类
 * struts2 Action 跳转会页面时候 需要在页面上显示的信息
 * 和如何显示
 * 和控制页面元素的信息内容
 * 与每个页面都用的show_action_message.jsp和utils.js,artDialog配合时候
 * @author HSWHM
 *
 */
public class ScriptMessageUtil {

	//private List<String> scriptMessages=new ArrayList<String>();
	
	/**
	 * dialog tips 1.5秒消失
	 */
	public static String tip(String message){
		
		return "art.dialog({time:'1.5', content:\""+filterString(message)+"\"});";
		//return  "art.dialog.tips(\""+message+"\", "+closeTime+");";
	}
	
	public static String alert(String message){
		//return "art.dialog({ icon: 'alert', content:\" "+filterString(message)+"\"});";
		return "alert(\""+filterString(message)+"\");";
	}
	
	public static String alertErro(String message){
		//return "art.dialog({icon: 'error', content:\"操作失败 : "+filterString(message)+"\"});";
		return "alert(\""+filterString(message)+"\");";
	}
	
	public static String alertSucceed(String message){
//		return "art.dialog({ icon: 'face-smile', content:\" "+filterString(message)+"\"});";
		return "alert(\""+filterString(message)+"\");";
	}
	
	public static String alertSucceed(){
//		return "art.dialog({icon: 'face-smile',content:'操作完成'});";
		return "alert('操作完成');";
	}
	
	public static String waring(String message){
//		return "art.dialog({icon: 'warning',content:\""+filterString(message)+"\"});";	
		return "alert('"+filterString(message)+"');";
	}
	
	
	enum ICON_TYPE{

		SUCCEED("succeed"),ERRO("error"),ALERT("alert"),CONFIRM("confirm"),QUESTION("question"),WARNING("warning");
		
		private String value = "";
		
		private ICON_TYPE(String name){
			
		}
		public String getValue(){
			return value;
		}
	}
	
	public static String filterString(String javaString){
		if(javaString==null)return "";
		StringBuilder jsString = new StringBuilder();
		jsString.append(javaString);
		
		return jsString.toString();
	}
	

}
